#include<iostream>
using namespace std;
int num[1000][3];
int count=0;
void Fun(int front,int rear){
    if(rear-front<1)return;
    int k=rear+front,s=k/2;
    num[count][0]=front;
    num[count][1]=k-s-1;
    num[count++][2]=rear;
    Fun(front,s);
    Fun(s+1,rear);

}
int main(){
    int n;cin>>n;
    Fun(1,n);
    cout<<count<<endl;
    for(int i=0;i<count;i++)
        cout<<num[i][0]<<" "<<num[i][1]<<" "<<num[i][2]<<endl;
    return 0;
}